"""
提示词模板模型
"""

from sqlalchemy import Column, Integer, String, DateTime, Text, Boolean, JSON
from sqlalchemy.sql import func
from app.database import Base


class PromptTemplate(Base):
    """提示词模板表"""
    
    __tablename__ = "prompt_templates"
    
    id = Column(Integer, primary_key=True, index=True, comment="模板ID")
    name = Column(String(100), nullable=False, comment="模板名称")
    description = Column(Text, comment="模板描述")
    content = Column(Text, nullable=False, comment="模板内容")
    variables = Column(JSON, comment="模板变量列表")
    category = Column(String(50), comment="模板分类")
    tags = Column(JSON, comment="标签列表")
    is_active = Column(Boolean, default=True, comment="是否激活")
    is_public = Column(Boolean, default=False, comment="是否公开")
    usage_count = Column(Integer, default=0, comment="使用次数")
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="更新时间")
    
    def __repr__(self):
        return f"<PromptTemplate(id={self.id}, name='{self.name}')>"
